package cn.edu.suda.schoolBus.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.edu.suda.schoolBus.bean.SchoolBus;
import cn.edu.suda.schoolBus.service.SchoolBusService;
import cn.edu.suda.schoolBus.util.ResultUtil;

@Controller
public class SchoolBusController {

	@Autowired
	private SchoolBusService schoolBusService;

	@RequestMapping("/addSchoolBus")
	@ResponseBody
	public Map<String, Boolean> addSchoolbus(SchoolBus schoolBus) {
		return ResultUtil.getResult(schoolBusService.addSchoolBus(schoolBus));
	}

	@RequestMapping("/getSchoolBus")
	@ResponseBody
	public Map<String, Object> getSchoolBus(int page, int rows) {
		return schoolBusService.getSchoolBus(page, rows);
	}

	@RequestMapping("/getSchoolBusByNumber")
	@ResponseBody
	public Map<String, Boolean> getSchoolBus(String sbNumber) {
		return ResultUtil.getResult(schoolBusService.getSchoolBus(sbNumber));
	}

	@RequestMapping("/deleteSchoolBus")
	@ResponseBody
	public Map<String, Boolean> deleteSchoolbus(String ids) {
		return ResultUtil.getResult(schoolBusService.deleteByPrimaryKey(ids));
	}

	@RequestMapping("/editSchoolBus")
	@ResponseBody
	public Map<String, Boolean> editSchoolbus(SchoolBus schoolBus) {
		return ResultUtil.getResult(schoolBusService.editSchoolBus(schoolBus));
	}

	@RequestMapping("/getDeparturePassengerNumber")
	@ResponseBody
	public List<SchoolBus> getDeparturePassengerNumber() {
		return schoolBusService.getSchoolBus();
	}

}
